package com.company;

/**
 * Created by asus on 2017/11/28.
 */
public class Enum {
    public enum Operation{
        PLUS("+") {double apply(double x, double y){return x + y;}},
        MINUS("-") {double apply(double x, double y){return x - y;}},
        TIMES("*") {double apply(double x, double y){return x * y;}},
        DIVIDE("/") {double apply(double x, double y){return x / y;}};

        abstract double apply(double x, double y);
        private final String symbol;
        Operation(String symbol){this.symbol = symbol;}
        @Override
        public String toString(){return symbol;}
    }

    public static void main(String[] args) {
        double x = 2;
        double y = 4;
        for (Operation op : Operation.values()){
            System.out.printf("%f %s %f = %f%n", x, op, y, op.apply(x,y));
        }
        while (true){
            System.out.println("1");
        }
    }
}
